import http from "./http.js";
import config from "@/config/index.config.js";

// 用户登录
//export const postLogin = (data) => http.POST(`${config.baseUrl}/login`, data);


//首页广告显示屏
export const getBanners = (positionId,data) => http.GET(`${config.baseUrl}/api/ad/list/${positionId}?` + Date.parse(new Date()), data);



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////       商城使用         //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//获取商品列表
export const getGoodsList = (data) => http.GET(`${config.baseUrl}/api/goods/list?` + Date.parse(new Date()), data);

//获取商品
export const getGoodsById = (goodsId,data) => http.GET(`${config.baseUrl}/api/goods/info/${goodsId}?` + Date.parse(new Date()), data);

//按分类获取商品
export const getCategoryGoodsList = (categoryId,data) => http.GET(`${config.baseUrl}/api/goods/category/${categoryId}?` + Date.parse(new Date()), data);

//收藏夹
export const getCollectGoodsList = (data) => http.GET(`${config.baseUrl}/api/collect/list?` + Date.parse(new Date()), data);

//收藏
export const addCollect = (goodsId,data) => http.GET(`${config.baseUrl}/api/collect/add/${goodsId}?` + Date.parse(new Date()), data);
//取消收藏
export const delCollect = (goodsId,data) => http.GET(`${config.baseUrl}/api/collect/del/${goodsId}?` + Date.parse(new Date()), data);
//历史足迹
export const getFootpintGoodsList = (data) => http.GET(`${config.baseUrl}/api/foot/list?` + Date.parse(new Date()), data);

//加入购物车
export const addToCart = (productId,data) => http.GET(`${config.baseUrl}/api/cart/addcart/${productId}?` + Date.parse(new Date()), data);
//购物车数量
export const cartProductNum = (data) => http.GET(`${config.baseUrl}/api/cart/cartnum?` + Date.parse(new Date()), data);
//直接购物
export const buyProduct = (productId,productNum,data) => http.GET(`${config.baseUrl}/api/order/newfromproduct/${productId}/${productNum}?` + Date.parse(new Date()), data);

//订单类
export const getOrderById = (orderId,data) => http.GET(`${config.baseUrl}/api/order/info/${orderId}?` + Date.parse(new Date()), data);

export const changeOrderAddress = (orderId,addressId,data) => http.GET(`${config.baseUrl}/api/order/changeaddress/${orderId}/${addressId}?` + Date.parse(new Date()), data);

export const myOrderList = (data) => http.GET(`${config.baseUrl}/api/order/list?` + Date.parse(new Date()), data);

export const myOrderListState = (state,data) => http.GET(`${config.baseUrl}/api/order/list/${state}?` + Date.parse(new Date()), data);

export const cancelOrder = (orderId,data) => http.GET(`${config.baseUrl}/api/order/cancel/${orderId}?` + Date.parse(new Date()), data);

export const confirmOrder = (orderId,data) => http.GET(`${config.baseUrl}/api/order/confirm/${orderId}?` + Date.parse(new Date()), data);

export const payingOrder = (orderId,data) => http.GET(`${config.baseUrl}/api/order/paying/${orderId}?` + Date.parse(new Date()), data);

export const deleteOrder = (orderId,data) => http.GET(`${config.baseUrl}/api/order/delete/${orderId}?` + Date.parse(new Date()), data);

//地址类
export const getAddress = (addressId,data) => http.GET(`${config.baseUrl}/api/address/info/${addressId}?` + Date.parse(new Date()), data);

export const getAddresses = (data) => http.GET(`${config.baseUrl}/api/address/list?` + Date.parse(new Date()), data);

export const saveAddress = (data) => http.POST(`${config.baseUrl}/api/address/save?` + Date.parse(new Date()), JSON.stringify(data.address));

export const saveAddressAddToOrder = (orderId,data) => http.POST(`${config.baseUrl}/api/address/saveaddtoorder/${orderId}?` + Date.parse(new Date()), JSON.stringify(data.address));

//h5 订单微信支付
export const wxPayByOrderId = (orderId,data) => http.GET(`${config.baseUrl}/api/pay/wx/${config.mpAppId}/order/${orderId}?` + Date.parse(new Date()), data);

//小程序订单微信支付
export const wxXcxPayByOrderId = (orderId,data) => http.GET(`${config.baseUrl}/api/pay/wx/${config.xcxAppId}/order/${orderId}?` + Date.parse(new Date()), data);


//健康数据
export const healthDataUrl = (data) => http.POST(`${config.baseUrl}/api/health/list?` + Date.parse(new Date()), data);


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////      微信登录、分享、支付相关      /////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//xcx微信Check code
export const getWxXcxCheckCode = (data) => http.GET(`${config.baseUrl}/wxlogin/xcxcheck/${config.xcxAppId}?` + Date.parse(new Date()), data);

//xcx微信静默登录Check code
export const getWxXcxSilentCheckCode = (data) => http.GET(`${config.baseUrl}/wxlogin/wxsilentcheck/${config.xcxAppId}?` + Date.parse(new Date()), data);

//h5微信Check code
export const getWxCheckCode = (data) => http.GET(`${config.baseUrl}/wxlogin/check/${config.mpAppId}?` + Date.parse(new Date()), data);

//h5微信静默登录Check code
export const getWxSilentCheckCode = (data) => http.GET(`${config.baseUrl}/wxlogin/checksilentlogincode/${config.mpAppId}?` + Date.parse(new Date()), data);

//h5微信服务端签名
export const jsapiSignature = (data) => http.GET(`${config.baseUrl}/api/wx/jsapisignature/${config.mpAppId}?` + Date.parse(new Date()), data);

//h5商品直接微信支付
export const wxPayByGoodsId = (goodsId,goodsNum,data) => http.GET(`${config.baseUrl}/api/pay/wx/${config.mpAppId}/goods/${goodsId}/${goodsNum}?` + Date.parse(new Date()), data);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////      头条登录      /////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//xcx微信Check code
export const getTtXcxCheckCode = (data) => http.GET(`${config.baseUrl}/ttlogin/ttcheck/${config.ttAppId}?` + Date.parse(new Date()), data);
//xcx微信静默登录Check code
export const getTtXcxSilentCheckCode = (data) => http.GET(`${config.baseUrl}/ttlogin/ttsilentcheck/${config.ttAppId}?` + Date.parse(new Date()), data);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////               小说              /////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//书名列表
export const getBookIndex = (level,data) => http.GET(`${config.baseUrl}/apin/category/list/${level}?` + Date.parse(new Date()), data);

export const getHomeBookIndex = (data) => http.GET(`${config.baseUrl}/apin/category/home?` + Date.parse(new Date()), data);

//获取文章列表
export const getArticleList = (categoryId,data) => http.GET(`${config.baseUrl}/apin/novel/category/${categoryId}?` + Date.parse(new Date()), data);
//获取文章
export const getArticleById = (articleId,data) => http.GET(`${config.baseUrl}/apin/novel/info/${articleId}?` + Date.parse(new Date()), data);

export const nextArticle = (articleId,data) => http.GET(`${config.baseUrl}/apin/novel/next/${articleId}?` + Date.parse(new Date()), data);

export const lastArticle = (articleId,data) => http.GET(`${config.baseUrl}/apin/novel/last/${articleId}?` + Date.parse(new Date()), data);

//收藏夹--书名
export const getCollectCategoryList = (data) => http.GET(`${config.baseUrl}/apin/collect/list?` + Date.parse(new Date()), data);

//收藏
export const addCategoryCollect = (categoryId,data) => http.GET(`${config.baseUrl}/apin/collect/add/${categoryId}?` + Date.parse(new Date()), data);
//取消收藏
export const delCategoryCollect = (categoryId,data) => http.GET(`${config.baseUrl}/apin/collect/del/${categoryId}?` + Date.parse(new Date()), data);

